//拼团报名列表
exports.search_name_or_address_or_tags = function (req, res) {

    //获取restful参数 
    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    var skip  =  restfulParams.skip == undefined  ? 0 : restfulParams.skip;
    var limit =  restfulParams.limit == undefined ? config.publicConfig.LIMIT : restfulParams.limit;


    //任务流创建
    async.waterfall([

        function(cb){

            
            R.SEND_HTTP(
                req,
                {
                    url    : CORE_APIConfig.coreAPI.search_name_or_address_or_tags + "/skip/"+skip+"/limit/" + limit,
                    method : 'POST',
                    data : {
                        keywords : restfulParams.keywords
                    }
                },
                function (err, data) {

                    //判断是否有错误信息
                    if (err) {
                        return cb(err, data);
                    }

                    resultData.organizationData = data.data;

                    cb();
                }
            );

        },

             //计算和自己的距离
             function(cb){

                for(var i = 0;i<resultData.organizationData.length;i++){
    
                    var tempLng = resultData.organizationData[i].o_longitude;
                    var tempLat = resultData.organizationData[i].o_latitude;
                    var distance = (common.GetDistance(tempLat,tempLng,restfulParams.lat,restfulParams.lng)).toFixed(1);    
                    resultData.organizationData[i].distance = distance;
    
                }
    
                cb();
    
            },
    
            

        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

}